import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[] array = notOrtherArray(10);
        testQuickSort1(array);
        System.out.println("=======================");
        int[] arr={6,1,2,7,9,3,4,5,10,8};
        testQuickSort2(arr);
    }

    public static void testQuickSort1(int[] arr){//递归实现
        arr=Arrays.copyOf(arr,arr.length);
        long startTime = System.currentTimeMillis();
        Repetition_Sort.quickSort(arr);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+ (endTime-startTime));
    }

    public static void testQuickSort2(int[] arr){//非递归实现
        arr=Arrays.copyOf(arr,arr.length);
        System.out.println("排序前："+Arrays.toString(arr));
        long startTime = System.currentTimeMillis();
        Repetition_Sort.quickSort2(arr);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+ (endTime-startTime));
        System.out.println("快速排序非递归排序："+Arrays.toString(arr));
    }

    public static int[] notOrtherArray(int num){
        int[] arr= new int[num];
        int j =0;
        for (int i = num; i > 0  ; i--) {
            arr[j]=i;
            j++;
        }
        return arr;
    }

    public static void main2(String[] args) {
        Repetition_Sort repetition_sort = new Repetition_Sort();
        int[] arr = {10,9,8,5,6,4,7};
        int[] arr2=Arrays.copyOf(arr,arr.length);
        System.out.println("排序前："+ Arrays.toString(arr2));
        repetition_sort.selectSort(arr2);
        System.out.println("排序后："+ Arrays.toString(arr2));

        System.out.println("====================");

        int[] arr3={5,1,1,2,0,0};
        System.out.println("排序前："+ Arrays.toString(arr3));
        repetition_sort.heapSort(arr3);
        System.out.println("排序后："+ Arrays.toString(arr3));

        System.out.println("====================");

        int[] arr4=Arrays.copyOf(arr,arr.length);
        System.out.println("快速排序前："+ Arrays.toString(arr4));
        repetition_sort.quickSort(arr4);
        System.out.println("快速排序后："+ Arrays.toString(arr4));

        System.out.println("====================");

        int[] arr5=Arrays.copyOf(arr,arr.length);
        System.out.println("排序前："+ Arrays.toString(arr5));
        repetition_sort.bubbleSort(arr5);
        System.out.println("排序后："+ Arrays.toString(arr5));

        System.out.println("====================");
        int[] arr6={10,6,7,1,3,9,4,2};
        repetition_sort.mergeSort1(arr6);
        System.out.println(Arrays.toString(arr6));
        System.out.println("====================");

        int[] arr7={10,6,7,1,3,9,4,2};
        Repetition_Sort.mergeSort2(arr7);
        System.out.println(Arrays.toString(arr7));

        int[] arr8={10,6,7,1,3,9,4,2};
        Repetition_Sort.countSort(arr8);
        System.out.println("计数排序："+Arrays.toString(arr8));
    }

    public static void main1(String[] args) {
        Sort sort = new Sort();
        int[] arr ={10,2,5,7,8};
        System.out.println("排序前："+ Arrays.toString(arr));
        sort.insertSort2(arr);
        System.out.println("排序后："+ Arrays.toString(arr));

        int[] arr2 ={10,2,5,7,8};
        System.out.println("排序前："+ Arrays.toString(arr2));
        sort.shellSort(arr2);
        System.out.println("排序后："+ Arrays.toString(arr2));

        int[] array={9,1,2,5,7,4,8,6,3,5};
//        int[] arr4=Arrays.copyOf(array,array.length);
//        System.out.println("排序前："+ Arrays.toString(arr4));
//        sort.selectSort(arr4);
//        System.out.println("排序后："+ Arrays.toString(arr4));

        int[] arr5=Arrays.copyOf(array,array.length);
        System.out.println("排序前："+ Arrays.toString(arr5));
        sort.selectSort(arr5);
        System.out.println("排序后："+ Arrays.toString(arr5));
    }
}
